package org.example.nuaael;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @Author : zhangbo
 * @data : 2024/6/25
 * @description :
 */
public class test5 {
    public static void main(String[] args) {
        // 假设今天是 2024-06-25
        String todayDate = "2024-06-25";
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");

        // 将字符串转换为 LocalDate 对象
        LocalDateTime today = LocalDateTime.parse(todayDate, formatter);

        // 将数字 15 设置为时间的小时部分，分钟和秒设置为 0
        LocalDateTime timeWithHour15 = today.withHour(15).withMinute(0).withSecond(0);

        // 格式化输出
        DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String formattedTime = timeWithHour15.format(outputFormatter);

        // 打印结果
        System.out.println("The time with hour 15 is: " + formattedTime);
    }
}
